package com.itheima.mall.service.PmsService;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.mall.mapper.PmsMapper.PmsProductCategoryMapper;
import com.itheima.mall.service.pmsService.PmsProductCategoryApi;
import com.itheima.pojo.pms.PmsProductCategory;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class PmsProductCategoryApiImpl implements PmsProductCategoryApi {

    @Autowired
    private PmsProductCategoryMapper pmsProductCategoryMapper;

    @Override
    public void create(PmsProductCategory pmsProductCategory) {
        pmsProductCategoryMapper.insert(pmsProductCategory);
    }

    @Override
    public void removeById(Long id) {
        pmsProductCategoryMapper.deleteById(id);
    }

    @Override
    public void update(PmsProductCategory pmsProductCategory) {
        pmsProductCategoryMapper.updateById(pmsProductCategory);
    }

    @Override
    public List<PmsProductCategory> withChildren(LambdaQueryWrapper<PmsProductCategory> wrapper) {
        return pmsProductCategoryMapper.selectList(wrapper);
    }

    @Override
    public Page<PmsProductCategory> page(Page<PmsProductCategory> pageInfo, LambdaQueryWrapper<PmsProductCategory> wrapper) {
        return null;
    }

    @Override
    public void updateById(List<PmsProductCategory> categoryList) {
        for (PmsProductCategory pmsProductCategory : categoryList) {
            pmsProductCategoryMapper.updateById(pmsProductCategory);
        }
    }

    @Override
    public PmsProductCategory selectById(Long id) {
        return pmsProductCategoryMapper.selectById(id);
    }

    @Override
    public List<PmsProductCategory> selectByIds(List<Long> ids) {
        return pmsProductCategoryMapper.selectBatchIds(ids);
    }
}
